Understanding the basics of CSS for styling web pages
Selectors allow you to target HTML elements to apply styles. Common selectors include:
p { color: red; }
This would change all <p>
elements to red.
CSS properties define how an element should look. For example:
h1 { font-size: 24px; }
This would set the font size of all <h1>
elements to 24px.
Colors can be applied using color names, hex values, RGB, etc. Try the examples below:
CSS can also control the layout of elements. Here's an example of a simple box with a border:
CSS is used to create layouts like flexbox and grid. Here's a simple layout using flexbox: